/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package compilador.AnalisadorSemantico;

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Leles
 */
public class Semantico {
    
    static protected int x;
    
    private String outFilePath;
    private FileWriter charStream;
    
    PrintStream stream;// = System.out;
            
    public GeracaoDeCodigo Cod;

    public boolean EscreveCodigo (){
        //try {
            
            stream.print(Cod.RTE_Inicio_Prog);
            stream.print(Cod.Constantes);
            stream.print(Cod.Codigo);
            
            //System.out.println(Cod.Codigo);
            System.out.println(outFilePath);
        /*} catch (IOException ex) {
        Logger.getLogger(Semantico.class.getName()).log(Level.SEVERE, null, ex);
        return false;
        }*/
        
        return true;
    }
    
    public Semantico(String outFileStart, String outFileExtension) {
        //this.outFilePath = outFilePath;
        int i = 0;
        try{
            do {
                outFilePath = outFileStart + i + outFileExtension;
                charStream = new FileWriter(outFilePath); 
                stream = new PrintStream(outFilePath); 
                i++;
            } while (charStream == null);
         
        } catch(IOException e){
           System.out.println("Exception e: " + e.getMessage()); // Se não conseguir ler avisa o porque
        }     
        Cod = new GeracaoDeCodigo();
    }

    
    
}
